<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

/* if($_POST['submit']=='删除'){
	if(empty($_POST["cbid"])) show_automsg('请先选择要删除的记录！',$GLOBALARR['curl'],1);
	$u_id=implode(",",$_POST["cbid"]);

	$db->sitedbexec("delete from ld_bank where id in($u_id)");

	record_log('删除银行信息');
	show_automsg('删除成功！',$GLOBALARR['curl']);
} */

$pagecount=getnums($_GET["pagecount"],$GLOBALARR['pagecount']);
$option=getnums($_GET['option'],1);
$orderby=getnums($_GET['orderby'],1);
$quser=trim($_GET['quser']);

$tmp_arr['toption'].='<a href="'.getqueurl('option',1).'" class="'.geteqval(array($option,1,'taselbtn','thabtn')).'">前台登录日志</a><a href="'.getqueurl('option',2).'" class="'.geteqval(array($option,2,'taselbtn','thabtn')).'">后台登录日志</a><a href="'.getqueurl('option',3).'" class="'.geteqval(array($option,3,'taselbtn','thabtn')).'">前台操作日志</a><a href="'.getqueurl('option',4).'" class="'.geteqval(array($option,4,'taselbtn','thabtn')).'">后台操作日志</a>';

$tmp_arr['torderby']='<a href="'.getqueurl('orderby',geteqval(array($orderby,1,'2','1'))).'" class="'.((strstr($orderby,'1')||strstr($orderby,'2'))?"tpaixusel":"tpaixu").'">'.geteqval(array($orderby,1,'时间↓','时间↑')).'</a>';

if(is_array($GLOBALARR['jjname'])){
	foreach ($GLOBALARR['jjname'] as $k => $v) {
		$tmp_arr['tcolor'].='<a href="javascript:;" class="theacolor levelcolor'.$k.'">'.$v.'</a>';
	}
}

$condition=' where 1=1 ';

if($quser){
	if(strstr($quser,'-')){
		$qdate=explode('-',$quser);
		if($qdate[0]) $condition.=" and from_unixtime(add_time,'%Y')=".$qdate[0]."";
		if($qdate[1]) $condition.=" and from_unixtime(add_time,'%m')=".$qdate[1]."";
		if($qdate[2]) $condition.=" and from_unixtime(add_time,'%d')=".$qdate[2]."";
	}else{
		$condition.=" and uname like '%".$quser."%'";
	}
}
if($option==1) $condition.=" and ll_status = 0 ";
if($option==2) $condition.=" and ll_status = 1 ";
if($option==3) $condition.=" and log_type = 0 ";
if($option==4) $condition.=" and log_type = 1 ";


$order='';
if($option==1 || $option==2){
	if($orderby==1) $order=' order by ll_time desc';
	if($orderby==2) $order=' order by ll_time asc';
}else{
	if($orderby==1) $order=' order by login_time desc';
	if($orderby==2) $order=' order by login_time asc';
}

if($option==1 || $option==2){
	$tmp_arr['tth']='<th>序号</th><th>会员账号</th><th>姓名</th><th>登录时间</th><th>登录IP</th>';
}else{
	$tmp_arr['tth']='<th>序号</th><th>会员账号</th><th>姓名</th><th>登录时间</th><th>操作</th>';
}

if($option==1 || $option==2){
	$psql="select count(0) from ld_login_log $condition";
}else{
	$psql="select count(0) from ld_log $condition";
}
$db->query($psql,3);
$pcount=$db->fval;
$pagecount=$pagecount;   //每页条数 
$astr="&lsaction=ttlog&pagecount=$pagecount&orderby=$orderby&option=$option&quser=$quser";	  //Url
$pagearr=pagelist($pagecount,$pcount,$astr);
$offset=$pagearr[1];
if($option==1 || $option==2){
	$sql="select * from ld_login_log  $condition $order limit $offset,$pagecount";
}else{
	$sql="select * from ld_log  $condition $order limit $offset,$pagecount";
}

$db->query($sql);
$ii=0;
if($option==1 || $option==2){
	foreach ($db->rs as $k => $v) {
		$ii++;
		$serialid=($pagearr[2]-1)*$pagecount+$ii;
		$rm=$member->getum($v['uname'],'real_name,user_jibie');
		$rc=$member->getuv($v['uname'],'user_level');
		$tmp_arr['ttr'].='<tr class="levelcolor'.$rc['user_level'].'">
							
							<td><span  title="'.$v["id"].'">'.$serialid.'</span></td>
							<td>'.$v['uname'].'</td>
							<td>'.$rm['real_name'].'</td>
							<td>'.date("Y-m-d H:i:s",$v['ll_time']).'</td>
							<td>'.$v['loginip'].'</td>
							</tr>';
	}
}else{
	foreach ($db->rs as $k => $v) {
		$ii++;
		$serialid=($pagearr[2]-1)*$pagecount+$ii;
		$rm=$member->getum($v['uname'],'real_name,user_jibie');
		$rc=$member->getuv($v['uname'],'user_level');
		$tmp_arr['ttr'].='<tr class="levelcolor'.$rc['user_level'].'">
							
							<td><span  title="'.$v["id"].'">'.$serialid.'</span></td>
							<td>'.$v['uname'].'</td>
							<td>'.$rm['real_name'].'</td>
							<td>'.date("Y-m-d H:i:s",$v['login_time']).'</td>
							<td>'.$v['content'].'</td>
							</tr>';
	}
}

$tmp_arr['tcount']=$pcount;
$tmp_arr['ttitle']=getmenu($GLOBALARR['menu'],'ttlog');
$tmp_arr['tpage']=$pagearr[0];
admin_two($tmp_arr);

?>